<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('member_list'); $starttimer = microtime(true);
$checkPagenum = isset($checkPagenum)?  $checkPagenum  : $cfg_pagenum;
$keyword = isset($keyword) ? trim($keyword) : '';?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>会员管理</title>
<link href="templates/css/style.css" rel="stylesheet" type="text/css" />
<link href="templates/css/pagination.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/layindex.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
<script type="text/javascript" src="templates/js/forms.func.js"></script>
<script type="text/javascript">

function checkPagenum(id)
{	
	var pn = document.getElementById(id).value; 
	var url=window.location.search;
	location.href=changeURLArg(url,'checkPagenum',pn);
};


</script>
</head>

<body class="mainbody">
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <span>会员管理</span>
  <a href="javascript:location.reload();" class="reload">刷新</a>
</div>
<!--/导航栏-->

<!--工具栏-->
<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"></a>
      <div class="l-list">
        <ul class="icon-list">
		 <?php if(IsModel('member','add',1)!=false) echo'<li><a class="add" href="member_add.php"><i></i><span>新增</span></a></li>';?>
          <li><a class="all" href="javascript:;" onclick="checkAll(this);"><i></i><span>全选</span></a></li>
		 <?php if(IsModel('member','del',1)) echo'<li><a href="javascript:SubUrlParam(\'member_save.php?action=delall\')" onclick="return ConfDelAll(0);" class="del"><i></i><span>删除</span></a></li>';?>
        </ul> 
	
      </div>
      <div class="s-list">
	  
	<form name="form3" id="form3" method="get" action="member.php">
	  	<div class="rule-single-select">  
		<select name="usermodel"  onchange="func('usermodel')"  id="usermodel">
			<option selected="selected" value="all">会员模型</option>
			<?php
			$dosql->Execute("SELECT * FROM `#@__usermodel` ORDER BY id ASC");
			while($row = $dosql->GetArray())
			{	if(@$usermodel==$row['id']) $select='selected="selected"';else $select=''; 
				echo '<option '.$select.' value="'.$row['id'].'">'.$row['modeltitle'].'</option>';
			}
			?></select>
         </div>
		<div class="rule-single-select">  
		<select name="usergroup" onchange="func('usergroup')" id="usergroup">
			<option selected="selected" value="all">全部会员组</option>
			<?php
			$dosql->Execute("SELECT * FROM `#@__usergroup` ORDER BY id ASC");
			while($row = $dosql->GetArray())
			{	if(@$usergroup==$row['id']) $select='selected="selected"';else $select=''; 
				echo '<option '.$select.' value="'.$row['id'].'">'.$row['groupname'].'</option>';
			}
			?></select>
         </div>
		  <div class="rule-single-select">
			 <select name="checkinfo"  onchange="func('checkinfo')" id="checkinfo">
				<option selected="selected" value="all">状态</option>
				<option <?php if(@$checkinfo=='true') echo 'selected="selected"';?> value="true">正常</option>
				<option <?php if(@$checkinfo=='false') echo 'selected="selected"';?> value="false">锁定</option>
			</select>
          </div>
	
		 <div class="single-select">
        <input name="keyword" type="text" id="keyword" class="keyword"  value="<?php echo $keyword;?>"/>
		</div> 
		<div class="single-select">
		    <input  class="btn-search" type="submit" value="搜索" style="cursor:pointer;"></div>
	</form>
      </div>
    </div>
  </div>
</div>
<!--/工具栏-->
<form method="post" action="" id="form">
<!--列表-->
<div class="table-container">

  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>
		<th width="5%">选择</th>
		<th width="5%">ID</th>
			<th width="10%">头像</th>
			<th width="15%">用户名</th>
			<th width="10%">用户组</th>
			<th width="10%">注册ip</th>
			<th width="15%">最后登录</th>
			<th width="10%">金钱</th>
			<th width="10%">积分</th>
		<th width="10%" >操作</th>
    </tr>
  
  	<?php
			$sql ="SELECT * FROM `#@__member` where id>0 ";

		if(!empty($keyword)) $sql .= " AND (username LIKE '%$keyword%')";
		if(!empty($usermodel)) 
		{
			if($usermodel=='all')
			{
				$sql .='';
			}
			else{$sql .= " and `modelid` =  '$usermodel'";}
			
		}
		if(!empty($usergroup)) 
		{
			if($usergroup=='all')
			{
				$sql .='';
			}
			else{$sql .= " and `groupid` =  '$usergroup'";}
			
		}
			if(!empty($checkinfo))
		{
				switch($checkinfo)
			{
				case 'true':
						$sql .= "AND checkinfo='true'";
					break;
				case 'false':
						$sql .= "AND checkinfo='false'";
					break;
				default:
				;
			}
		}
		$dopage->GetPage($sql,$checkPagenum);

		while($row = $dosql->GetArray())
		{
			$usergroup = '';
			$dosql->Execute("SELECT * FROM `#@__usergroup`",$row['id']);
			while($row2 = $dosql->GetArray($row['id']))
			{
				if($row['groupid'] == $row2['id'])
				{
					$usergroup = '<span style="color:'.$row2['color'].'">'.$row2['groupname'].'</span>';
				}
			}

			if($usergroup == '')
			{
				
					$usergroup = '参数获取失败';
				
			}
			
			$oauthico = '';

			if($row['qqid'] != '')
				$oauthico .= '<span class="qqico" title="QQ账号绑定"></span>';

			if($row['weiboid'] != '')
				$oauthico .= '<span class="weiboico" title="微博账号绑定"></span>';
			
			//修改权限
			if(IsModel('member','update',1)==true)
				$updatestr = '<a href="member_update.php?id='.$row['id'].'"">修改</a>';
			else
				$updatestr = '修改';
			
			//删除权限
			if(IsModel('member','del',1)==true)
				$delstr = '<a href="member_save.php?action=del&id='.$row['id'].'" onclick="return ConfDel(0)">删除</a>';
			else
				$delstr = '删除';
			
		?>
		<tr align="center">
			<td ><span class="checkall" style="vertical-align:middle;"><input type="checkbox" name="checkid[]" value="<?php echo $row['id']; ?>" /></span></td>
			<td> <?php if($row['checkinfo'] == 'false') echo '<span class="padlock"><i title="用户被锁定"></i></span>';?> <?php echo $row['id']; ?></td>
			<td><span class="thumbs" style="width:20px; height:20px"><img src="../data/avatar/index.php?uid=<?php echo $row['id']; ?>&size=small&rnd=<?php echo GetRandStr(); ?>" width="20" height="20" /></span></td>
			<td><?php echo $oauthico.$row['username']; if($row['enteruser'] == 1) echo '<span class="vippic"><i title="认证用户"></i></span>';?> </td>
			<td><?php echo $usergroup;?></td>
			<td><?php echo $row['regip'];?></td>
			<td class="number"><?php echo GetDateMk($row['logintime']); ?>
				<?php echo MyDate('H:i:s',$row['logintime']); ?></td>
			<td><?php echo $row['amount']; ?></td>
			<td><?php echo $row['integral']; ?></td>
			<td class="action endCol"><span><?php echo $updatestr; ?></span> | <span class="nb"><?php echo $delstr; ?></span></td>
		</tr>
		<?php
		}
		?>
		 <?php

//判断无记录样式
if($dosql->GetTotalRow() == 0)
{
	echo '<tr><td align="center" colspan="10">暂无记录</td></tr>';
}
?>
  </table>
</div>
<!--/列表-->
<!--内容底部-->
<div class="line20"></div>
<div class="pagelist">
 <div class="l-btns">
    <span>显示</span><input name="txtPageNum" type="text" value="<?php echo $checkPagenum;?>"  onblur="checkPagenum(this.id)"  onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="txtPageNum" class="pagenum" onkeydown="return checkNumber(event);" /><span>条/页</span>
  </div>
  <?php echo $dopage->GetList($sql); ?>
  <div class="l-btns"><span>
<?php 
$stoptimer = microtime(true);
$timer = $stoptimer-$starttimer;
echo " $timer s";?></span>
</div>
</div>
<!--/内容底部-->
</form>
</body>
</html>
